<template>
	<view class="container user">
		我的页面
		<button @click="goLogin">去登录</button>
	</view>
</template>
<script lang="ts" setup>
	import ajax from "../../api/index";
	import { onShow } from "@dcloudio/uni-app";
	import { ref } from "vue";
	//存储用户信息
	const userInfo = ref<any>({});
	//个人中心页面的钩子-页面显示即执行一次
	onShow(() => {
		showUser();
	});
	const goLogin = () => {
		console.log("去登录了")
		uni.navigateTo({
			url: "/pages/login/index",
		});
	}

	const showUser = async () => {
		//每一次个人中心出来--->授权登录
		// const token = uni.getStorageSync("TOKEN");
		// if (token) {
		//   //获取用户信息:头像昵称,前提没有发一次，有了用户信息不需要再发请求获取用户信息
		//   if (!userInfo.value.nickname) {
		//     const result = await ajax.reqUserInfo();
		//     if (result.code == 200) {
		//       userInfo.value = result.data.item;
		//     }
		//   }
		// } else {
		//   uni.navigateTo({
		//     url: "/pages/login/index",
		//   });
		// }
	};
</script>
<style lang="less" scoped>
	.user {
		height: 100vh;
		background: #eee;
	}

	.info {
		background: #00cc99;

		&_title {
			height: 97px;
			padding: 0 24px;
			display: flex;
			align-items: center;
			border-bottom: 1rpx solid #eee;
			border-top: 1rpx solid #eee;

			&_logo {
				height: 60px;
				width: 60px;
				border-radius: 50%;
				background: #fff;
			}

			&_name {
				margin-left: 10px;
				color: #333;
				font-size: 20px;
				flex: 1;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				word-wrap: normal;
			}
		}

		&_list {
			display: flex;

			.info_item {
				width: 50%;
				text-align: center;

				.item_a {
					display: flex;
					flex-direction: column;
					align-items: center;
					padding: 24px 0;
				}

				.item_dsc {
					font-size: 14px;
					margin-top: 8px;
				}
			}
		}
	}

	.logout {
		height: 52px;
		line-height: 52px;
		text-align: center;
		margin-top: 10px;
		background: #00cc99;
	}

	.popup_height {
		height: 100px;
		width: 100%;
		background: #fff;
	}
</style>